package com.ruoyi.mall.controller;

import java.util.List;

import com.ruoyi.mall.domain.MallGoodsClass;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mall.domain.MallTimeWarehouse;
import com.ruoyi.mall.service.IMallTimeWarehouseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 抢购区仓库Controller
 *
 * @author ruoyi
 * @date 2022-02-23
 */
@RestController
@RequestMapping("/mall/mallTimeWarehouse")
public class MallTimeWarehouseController extends BaseController
{
    @Autowired
    private IMallTimeWarehouseService mallTimeWarehouseService;

    /**
     * 查询抢购区仓库列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTimeWarehouse:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallTimeWarehouse mallTimeWarehouse)
    {
        startPage();
        List<MallTimeWarehouse> list = mallTimeWarehouseService.selectMallTimeWarehouseList(mallTimeWarehouse);
        return getDataTable(list);
    }

    /**
     * 导出抢购区仓库列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTimeWarehouse:export')")
    @Log(title = "抢购区仓库", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MallTimeWarehouse mallTimeWarehouse)
    {
        List<MallTimeWarehouse> list = mallTimeWarehouseService.selectMallTimeWarehouseList(mallTimeWarehouse);
        ExcelUtil<MallTimeWarehouse> util = new ExcelUtil<MallTimeWarehouse>(MallTimeWarehouse.class);
        return util.exportExcel(list, "抢购区仓库数据");
    }

    /**
     * 获取抢购区仓库详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTimeWarehouse:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(mallTimeWarehouseService.selectMallTimeWarehouseById(id));
    }

    /**
     * 新增抢购区仓库
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTimeWarehouse:add')")
    @Log(title = "抢购区仓库", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallTimeWarehouse mallTimeWarehouse)
    {
        return toAjax(mallTimeWarehouseService.insertMallTimeWarehouse(mallTimeWarehouse));
    }

    /**
     * 修改抢购区仓库
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTimeWarehouse:edit')")
    @Log(title = "抢购区仓库", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallTimeWarehouse mallTimeWarehouse)
    {
        return toAjax(mallTimeWarehouseService.updateMallTimeWarehouse(mallTimeWarehouse));
    }

    /**
     * 删除抢购区仓库
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTimeWarehouse:remove')")
    @Log(title = "抢购区仓库", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mallTimeWarehouseService.deleteMallTimeWarehouseByIds(ids));
    }

    /**
     * 查询所属仓库
     */
    @GetMapping("/getRegionList")
    public AjaxResult getRegionList(MallTimeWarehouse mallTimeWarehouse)
    {
        List<MallTimeWarehouse> list = mallTimeWarehouseService.selectMallTimeWarehouseList(mallTimeWarehouse);
        return AjaxResult.success(list);
    }
}
